package com.ruoyi.report.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.report.domain.ReportOrginalimage;
import com.ruoyi.report.service.IReportOrginalimageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 原始记录附件图片Controller
 * 
 * @author lgq
 * @date 2023-05-25
 */
@RestController
@RequestMapping("/report/orginalimage")
public class ReportOrginalimageController extends BaseController
{
    @Autowired
    private IReportOrginalimageService reportOrginalimageService;

    /**
     * 查询原始记录附件图片列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ReportOrginalimage reportOrginalimage)
    {
        startPage();
        List<ReportOrginalimage> list = reportOrginalimageService.selectReportOrginalimageList(reportOrginalimage);
        return getDataTable(list);
    }

    /**
     * 导出原始记录附件图片列表
     */
    @Log(title = "原始记录附件图片", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ReportOrginalimage reportOrginalimage)
    {
        List<ReportOrginalimage> list = reportOrginalimageService.selectReportOrginalimageList(reportOrginalimage);
        ExcelUtil<ReportOrginalimage> util = new ExcelUtil<ReportOrginalimage>(ReportOrginalimage.class);
        return util.exportExcel(list, "orginalimage");
    }

    /**
     * 获取原始记录附件图片详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(reportOrginalimageService.selectReportOrginalimageById(id));
    }

    /**
     * 新增原始记录附件图片
     */
    @Log(title = "原始记录附件图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportOrginalimage reportOrginalimage)
    {
        return toAjax(reportOrginalimageService.insertReportOrginalimage(reportOrginalimage));
    }

    /**
     * 修改原始记录附件图片
     */
    @Log(title = "原始记录附件图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportOrginalimage reportOrginalimage)
    {
        return toAjax(reportOrginalimageService.updateReportOrginalimage(reportOrginalimage));
    }

    /**
     * 删除原始记录附件图片
     */
    @Log(title = "原始记录附件图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(reportOrginalimageService.deleteReportOrginalimageByIds(ids));
    }
}
